package com.rsk.dao.extend;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Component;


@Component
public class SysMenuExtend {
	
	public Map<String, Object> selectMenus(String menuName, String menuUrl){
		 // 拼接SQL语句
       StringBuilder sql = new StringBuilder("SELECT id,menu_name,menu_url,p_id,sort FROM sys_menus Where is_del = 0");
       
       // 查询需要的参数，先存进Map
       StringBuilder paramSql = new StringBuilder();
       Map<String, Object> paramMap = new HashMap<String, Object>();
       if (menuName != null && !menuName.isEmpty()) {
    	   paramSql.append(" and menu_name like :menuName");
    	   paramMap.put("menuName", "%" + menuName + "%");
       }
       if (menuUrl != null && !menuUrl.isEmpty()) {
    	   paramSql.append(" and menu_url like :menuUrl");
    	   paramMap.put("menuUrl", "%" + menuUrl + "%");
       }
       
       //排序
       StringBuilder orderSql = new StringBuilder();
       orderSql = orderSql.append(" order by sort");
       
       Map<String, Object> returnMap = new HashMap<String, Object>();
       returnMap.put("sql", sql.append(paramSql).append(orderSql));
       returnMap.put("paramMap", paramMap);
		return returnMap;
	}
}
 